﻿@model IEnumerable<trangbaocao.Models.Device_Stations_Parament_Using>

<div align="center"><h1>DANH MỤC THIẾT BỊ TRUYỀN DẪN TẠI TRẠM</h1></div>
<div class="container_12">
    <div class="grid_12">
        <!-- Notification boxes -->
        @if (TempData["msg"] != null)
        {                            
            <span class="notification n-success">@TempData["msg"]</span>
        }
        @if (TempData["error"] != null)
        {                            
            <span class="notification n-error">@TempData["error"]</span>
        } 
         @using (Html.BeginForm("Fill_Stations", "Manage_TruyenDan", FormMethod.Post, new { id = "Fill_Stations", name = "Fill_Stations" }))
        {
            
                   <div style="padding-left:5px; margin-bottom:5px; text-align:left; width:40%">
                   <lable style="margin-right:3px">Trung tâm: </lable>
                    @if (ViewBag.trungtam_id != null)
                        {  
                             
                            @Html.DropDownList("main_stations_id", ViewBag.trungtam_id as SelectList, "---Chọn trung tâm---")    
                            
                        }
                    </div>
                    <p style="text-align:left; width:56%;padding-left:5px">
                        <p style="text-align:left; width:40%;padding-left:5px; float:left">
                        Trạm:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                    @Html.DropDownList("stations_id", Enumerable.Empty<SelectListItem>(), "---Chọn nhà trạm---")
                        </p>
             <input class="submit-green" type="submit" value="Tìm kiếm" style="width:10%; margin-left:-50px"  />  
            </p><!-- Button -->  
        }  
        
        @using (Html.BeginForm("CheckedAction", "Manage_TruyenDan", FormMethod.Post, new { id = "CheckedAction", name = "CheckedAction" }))
        {           
            <!-- Button -->
            <div class="float-right">
                <a href="@Url.Action("AddDevice_Stations", "Device_Stations")" class="button">
                    <span>Thêm thiết bị <img src="../../Content/Body/Images/plus-small.gif"  width="12" height="9" alt="Thêm mới" /></span>  
                </a>
            </div> 
            <div class="module">
                <h2><span>@*Sample table*@</span></h2>                    
                <div class="module-table-body">
                    <div class="scrolling">
                        <div class="data-table" style="width:100%">
                            <table id="myTable" class="tablesorter">
                                <thead>
                                    <tr>
                                        <th style="width:8%">STT</th>
                                        <th style="width:12%">Cập nhật</th>
                                        <th style="width:30%;">Tên thiết bị</th>
                                        <th >Loại thiết bị</th>
                                        <th >Tên trạm</th>
                                        <th>Ngày lắp đặt</th>
                                    </tr>
                                </thead>
                            <tbody>
                        @{int stt = 0;}
                        @foreach (var item in Model)
                        {
                            stt++;
                            <tr>
                                <td class="align-center">@stt</td> 
                                <td align="center">
                                     <a href="@Url.Action("Parameter_Using_TruyenDan", "Manage_TruyenDan", new { device_stations_id = item.device_stations_id })"  class="button">
                                     <span><img src="../../Content/Body/Images/plus-small.gif"  width="12" height="9" alt="Thêm mới" /></span>  </a>
                                </td>                             
                                <td> @Html.DisplayFor(modelItem => item.name_device_stations)</td>
                                <td> @Html.DisplayFor(modelItem => item.sort_device_name)</td>
                                <td> @Html.DisplayFor(modelItem => item.name_stations)</td> 
                                <td> @Html.DisplayFor(modelItem => item.date_setup)</td>
                            </tr>
                        }   
                        </tbody>
                       
                        </table>
                      <input type="hidden" id = "device_id" value="0" />
                    </div>
                   </div> <!-- End data-table--> 
                    <div class="pager" id="pager">
                        <div>
                        <img class="first" src="../../Content/Body/Images/arrow-stop-180.gif"  alt="first"/>
                        <img class="prev" src="../../Content/Body/Images/arrow-180.gif" alt="prev"/> 
                        <input type="text" class="pagedisplay input-short align-center"/>
                        <img class="next" src="../../Content/Body/Images/arrow.gif" alt="next"/>
                        <img class="last" src="../../Content/Body/Images/arrow-stop.gif" alt="last"/> 
                        <select class="pagesize input-short align-center">
                            <option value="20" selected="selected">20</option>
                            <option value="30">30</option>
                            <option value="40">40</option>
                        </select>
                        </div>
                    </div>
                   
                    <div style="clear: both"></div>
               
                </div> <!-- End .module-table-body -->
            </div> <!-- End .module --> 
            <div class="bottom-spacing">
                
        </div>   
        }                                                                    
	</div> <!-- End .grid_12 -->            
    <div style="clear:both;"></div>            
</div> <!-- End .container_12 -->

<script type="text/javascript">
    $("#main_stations_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getStationsJson", "Device_Stations")',
            data: { MainStationId: $("#main_stations_id > option:selected").attr("value"), Order: "name" },
            success: function (data) {
                var items = [];
                items.push("<option>---Chọn nhà trạm---</option>");
                $.each(data, function () {
                    items.push("<option value=" + this.Value + ">" + this.Text + "</option>");
                });
                $("#stations_id").html(items.join(' '));
            }
        })
    });
</script>